/*
 * Copyright (C) 2013  Richard Schilling. All rights reserved.
 * contact: coderroadie@gmail.com
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package android.persist.annotation;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * {@code DataStoreField} is a field {@link Annotation} that specifies how a
 * field is persisted in a data store. It is required to use this annotation for
 * at least one of the fields in a class that is persisted (see {@see #key()}).
 * <p>
 * For example, when persisting fields to a SQLite database this annotation will
 * specify how to configure the database column for member {@code bar}.
 * 
 * <pre>
 * public class Foo {
 *     &#064;DataStoreField(key = true)
 *     private String bar;
 * }
 * </pre>
 * 
 * @author Richard Schilling (coderroadie@gmail.com)
 * @since 1.0
 */
@Target(FIELD)
@Retention(RUNTIME)
public @interface DataStoreField {

    /**
     * All fields of a class annotated with {@code key=true} will be combined to
     * form the unique compound key for the persisted class. At least one field
     * in a class must be annotated with {@code key=true}.
     * 
     * @since 1.0
     */
    boolean key() default false;

    /**
     * If {@code unique=true} the data store will ensure that the value of the
     * field is unique in the class' data store.
     * 
     * @since 1.0
     */
    boolean unique() default false;

    /**
     * All fields of a class annotated with {@code uniqueCombo=true} will be
     * combined to form a unique value the data store. This is useful to
     * creating unique combined keys with fields that are not annotated with
     * {@link #key()}.
     * 
     * @since 1.0
     */
    boolean uniqueCombo() default false;

    /**
     * Causes the data store to create an index for the field. One index for
     * each field is created.
     * 
     * @since 1.0
     */
    boolean index() default false;

}
